//
$(document).ready(function(){ 
	try
	{  
		togglestatus = function (id)
		{
			//~ alert(status);
			//~ if(status ==2)
			//~ {
				
			//~ }
			//~ return ;
			try
			{   
				var PATH_TO_TOGGLE_STATUS =  $('#togglestatusurl').html() ; //only way i found works   
				if(id>0 )
				{  
					$.ajax({
						type:'POST',
						url:PATH_TO_TOGGLE_STATUS,
						async:true,
						data:{ id: id}  ,
						error: function(e){ 
							//~ alert("error\n"+e.responseText); 
							alert("error\n	You may out of login session now. \n\n	Please logout and login again" ); 
						}, 
						beforeSend: function(){
							id = 'ts'+id; 
							document.getElementById(id).innerHTML = "toggling..."; 
							//document.getElementById(id).innerHTML =  $('#lodingimg').html() ; 
							//~ document.getElementById(id).html("toggling status..."); 
						},
						complete: function(){  
							
						},
						success:function(backdata)
						{
							document.getElementById(id).innerHTML = backdata;
						}
					});
				} 
			}
			catch(e)
			{
				//~ alert(e);
			}
		}
		
		$(".user_role").change(function(){
			var element = $(this).find('option:selected'); 
			var data = { user_id: $(this).attr('user_id'), user_role: element.attr('value')};
			$.ajax({
				url: webroot + 'admin/users/change_role',
				type:'POST',
				dataType: "json",
				cache: false,
				data: data,
				success:function(message)
				{
					if (message.status == 'fail') {
						$.jGrowl(message.message);
					}
				}
			});
		})
		
	}
	catch(e)
	{
		//~ alert(e);
	}
})
 
 